package com.teufandsub.socialproximity.logic;

import java.io.Serializable;

import org.json.JSONObject;

import android.util.Log;

import com.teufandsub.socialproximity.controller.Constants;

/**
 * @author Bastien Mathias <bastienmathias@gmail.com>
 * @author Antoine Teuf <antoine.teuf@gmail.com>
 * @version 1.0
 * @since 2013-05-22
 * 
 * Friend class, used to store User informations plus distance and matching.
 */

public class Friend extends User implements Serializable {
	
	private static final long serialVersionUID = 906499266968708912L;
	
	public static final String DISTANCE_NAME = "distance";
	public static final String MATCHING_NAME = "matching";
	
	private double distance;
	private int matchingPercent;
	
	public Friend(String firstname, String surname, String username, String email, int sex,
			boolean showRealName, double distance, int matchingPercent, boolean available) {
		super(firstname, surname, username, email, sex, showRealName, available);
		this.distance = distance;
		this.matchingPercent = matchingPercent;
	}
	
	public Friend(String pseudo){
		this("", "", pseudo, "", Friend.SEX_UNKNOWN, true, 0, 0, true);
	}
	
	public Friend(JSONObject object){
		super(object);
		try {
			this.distance        = object.getDouble(DISTANCE_NAME);
			this.matchingPercent = object.getInt(MATCHING_NAME);
		} catch (Exception e) {
			Log.e(Constants.APP_NAME, "user by JSONObject : " + e.toString());
		}
	}
	
	public double getDistance() {
		return distance;
	}
	
	public void setDistance(double distance) {
		this.distance = distance;
	}
	
	public int getMatchingPercent() {
		return matchingPercent;
	}
	
	public void setMatchingPercent(int matchingPercent) {
		this.matchingPercent = matchingPercent;
	}
}
